#include<stdio.h>
#include<stdlib.h>
#include"interim.h"

extern FILE *yyin;
extern int yylineno;
extern struct Node *head;
extern int is_error;

extern void yyrestart(FILE *input_file);

extern int yyparse(void);

int yylex();


int main(int argc, char **argv) {
    if (argc <= 1)
        return 1;
    FILE *f = fopen(argv[1], "r");
    if (!f) {
        perror(argv[1]);
        return 1;
    }
    yylineno = 1;
    yyrestart(f);
    yyparse();//词法、语法分析
    if (is_error == 0) {
        Program(head); //语义分析
        translate_Program(head, argv[2]); //中间代码生成
    }
    return 0;
}
